package cn.com.xjnt.vas.manage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.frameworks.core.repository.BaseRepository;
import com.frameworks.core.service.AbstractBaseService;

import cn.com.xjnt.vas.manage.domain.entity.Organization;
import cn.com.xjnt.vas.manage.repository.OrganizationRepository;
import cn.com.xjnt.vas.manage.service.OrganizationService;

@Service
@Transactional
public class OrganizationServiceImpl extends AbstractBaseService<Organization, Long> implements OrganizationService {

	@Autowired
	private OrganizationRepository organizationRepository;
	
	@Override
	public void save(Organization entity) {
		super.saveOrUpdate(entity);
	}

	@Override
	public void update(Organization entity) {
		Organization organization = super.findById(entity.getId());
		organization.setName(entity.getName());
		organization.setPriority(entity.getPriority());
		organization.setDescription(entity.getDescription());
		super.saveOrUpdate(organization);
	}

	@Override
	public List<Organization> findByParentId(Long parentId) {
		return organizationRepository.findByParentId(parentId);
	}

	@Override
	protected BaseRepository<Organization, Long> getBaseRepository() {
		return organizationRepository;
	}

}
